Add ChatCommands & New ConsoleCommands#939
Conversation
…,give,enchant,setblock,fill,time,weather,summon for Chat Commands, Added Summon in Console Commands And Edited Help For New parameters
|
Could you add /tp to coordinates? |
|
oh yeah i missed that completely im going to add /particle soon i will add that with this |
|
This is too messy. 4J had the basics of a command system setup and this just guts it in favor of a lot of hard coded magic values and fixed strings. This isn't a super maintainable way to have a command system unfortunately. If you refactor this to use the actual command system we could consider this, but make sure the isolated dedicated server project isn't already doing this before you waste time doing what's already been done. Thanks for the contribution. |
|
Thanks for the feedback. Could you pinpoint the code snippets for the "basics of a command system setup" you're talking about? I saw the "4J - TODO" on message 4J put on handlecommand, so thought that was the basic command system and just finished that part of the code. Also, could you specify more explicitly what numbers and variables you take issue with? I can add more comments to clarify what the variables, numbers, and some functions do, but I'm a little confused on what I'm doing wrong here. I checked the dedicated server fork and they haven't done anything for the ingame chat, just for commands input in the CMD terminal of the server. Aswell as this, the only non-server specific command they added was /gamemode, which is broken in the latest commit of the dedicated server. Commands already in the source code: Commands added by Kuwacoms dedicated server: Commands added by me: Before my edits there weren't any chat commands, only ones that worked in -server, or when Minecraft.Server.exe was ran. Now with my edits all these commands run both in chat and in -server. |
| return true; | ||
| } | ||
|
|
||
| if (action == L"summon") |
There was a problem hiding this comment.
In general, this particular non-modular implementation of commands in addition to the various independent command .cpp/.h files is confusing and not very good architecturally. Ideally these should be unified and all of our commands should be implemented in their own files. Having this duplicate implementation is messy and just not good for maintainability long term.
There was a problem hiding this comment.
Im not sure if you made a error in "should be implemented in their own files." because thats like that right now , because 4J had "independent command .cpp/.h files" i taken from there if i dont get you wrong you saying its better if gamemodecommand.cpp,teleportcommand.cpp etc comes in to single file just could be in playerconnection.cpp while checking logadminaction everything inside playerconnection or merging everycommand.cpp with already used commandispatcher.cpp
There was a problem hiding this comment.
I’m not sure what you mean
There was a problem hiding this comment.
"What is your opinion on how to fix the issue of 'various independent command .cpp/.h files is confusing' in this case?
Add everything to playerconnection.cpp and check everything there within the message (like console commands).
or
Merge every xxxcommand.cpp into commanddispatcher.cpp, and still use playerconnection to get args and send them directly to commanddispatcher rather than having enums and separate xxxcommand.cpp files."
There was a problem hiding this comment.
No, just define all commands in their own separate .cpp files. Again, there is no reason to have hard coded commands in any particular irrelevant file, the commands should be defined in their own files, registered somewhere centrally so they work in singleplayer and dedicated servers, and then all the weird hardcoded ones should be removed. That’s a far more maintainable pattern than what you’re proposing.
There was a problem hiding this comment.
did you read the code? by this answer i dont think you did it the commands are in the their own command files and with servercommandispatcher they get registered can you show me which hardcoded ones you talking about
There was a problem hiding this comment.
oh you mean the console commands i continued adding them same as direct usage i guess i could rewrite to use xxxcommand.cpp and bytearrayoutputstream same as playerconnection thanks for pointing this i will make it so use same methods as playerconnection also add some more needed commands and one day maybe open a pr again
Description
it adds the chat commands was left not finished
Changes
Added arg parsing to handlecommand() to check added commands also changed minecraftserver.cpp to add some commands to console
Previous Behavior
the game was looking messages starts with / but wasnt doing anything with it before changing there was a comment "4J - TODO"
Root Cause
not finished command system
New Behavior
it checks some keywords like /kill /gamemode if handlechat() finds / in the message start and check right args if not give a sendmessage to show args for that command
Fix Implementation
added arg parser to handlecommand() and with if statemens looked available commands if not give a sendmessage "unkown command"
AI Use Disclosure
ai was used to format some hard bracket insides and mapping item,tile,entity names for giveitem,setblock/fill,summon for time saving
Related Issues